using CollabApp.Domain.Services.Game;

namespace CollabApp.API.DTOs.Game;

/// <summary>
/// 游戏控制器相关的数据传输对象 - 画线圈地游戏API接口
/// </summary>

#region 请求DTOs

/// <summary>
/// 加入游戏请求
/// </summary>
public class JoinGameRequest
{
    /// <summary>游戏ID</summary>
    public Guid GameId { get; set; }
    
    /// <summary>玩家名称</summary>
    public string PlayerName { get; set; } = string.Empty;
}

/// <summary>
/// 玩家移动请求
/// </summary>
public class MovePlayerRequest
{
    /// <summary>游戏ID</summary>
    public Guid GameId { get; set; }
    
    /// <summary>新位置X坐标</summary>
    public float X { get; set; }
    
    /// <summary>新位置Y坐标</summary>
    public float Y { get; set; }
    
    /// <summary>是否正在绘制</summary>
    public bool IsDrawing { get; set; }
    
    /// <summary>时间戳</summary>
    public DateTime Timestamp { get; set; } = DateTime.UtcNow;
}

/// <summary>
/// 开始绘制请求
/// </summary>
public class StartDrawingRequest
{
    /// <summary>游戏ID</summary>
    public Guid GameId { get; set; }
    
    /// <summary>起始位置X坐标</summary>
    public float X { get; set; }
    
    /// <summary>起始位置Y坐标</summary>
    public float Y { get; set; }
}

/// <summary>
/// 停止绘制请求
/// </summary>
public class StopDrawingRequest
{
    /// <summary>游戏ID</summary>
    public Guid GameId { get; set; }
    
    /// <summary>结束位置X坐标</summary>
    public float X { get; set; }
    
    /// <summary>结束位置Y坐标</summary>
    public float Y { get; set; }
}

/// <summary>
/// 使用道具请求
/// </summary>
public class UseItemRequest
{
    /// <summary>游戏ID</summary>
    public Guid GameId { get; set; }
    
    /// <summary>道具类型</summary>
    public string ItemType { get; set; } = string.Empty;
    
    /// <summary>目标位置X坐标（可选）</summary>
    public float? TargetX { get; set; }
    
    /// <summary>目标位置Y坐标（可选）</summary>
    public float? TargetY { get; set; }
}

/// <summary>
/// 拾取道具请求
/// </summary>
public class PickupItemRequest
{
    /// <summary>游戏ID</summary>
    public Guid GameId { get; set; }
    
    /// <summary>道具ID</summary>
    public Guid ItemId { get; set; }
    
    /// <summary>道具位置X坐标</summary>
    public float X { get; set; }
    
    /// <summary>道具位置Y坐标</summary>
    public float Y { get; set; }
}

/// <summary>
/// 检查位置安全性请求
/// </summary>
public class CheckPositionSafetyRequest
{
    /// <summary>位置X坐标</summary>
    public float X { get; set; }
    
    /// <summary>位置Y坐标</summary>
    public float Y { get; set; }
}

#endregion

#region 响应DTOs

/// <summary>
/// 玩家状态响应
/// </summary>
public class PlayerStateResponse
{
    /// <summary>玩家ID</summary>
    public Guid PlayerId { get; set; }
    
    /// <summary>玩家名称</summary>
    public string PlayerName { get; set; } = string.Empty;
    
    /// <summary>玩家颜色</summary>
    public string PlayerColor { get; set; } = string.Empty;
    
    /// <summary>当前位置</summary>
    public PositionDto CurrentPosition { get; set; } = new();
    
    /// <summary>当前状态</summary>
    public string State { get; set; } = string.Empty;
    
    /// <summary>当前轨迹</summary>
    public List<PositionDto> CurrentTrail { get; set; } = new();
    
    /// <summary>拥有的领土</summary>
    public List<TerritoryDto> OwnedTerritories { get; set; } = new();
    
    /// <summary>领土总面积</summary>
    public float TotalTerritoryArea { get; set; }
    
    /// <summary>背包道具</summary>
    public List<string> Inventory { get; set; } = new();
    
    /// <summary>活跃效果</summary>
    public List<ActiveEffectDto> ActiveEffects { get; set; } = new();
    
    /// <summary>是否无敌</summary>
    public bool IsInvulnerable { get; set; }
    
    /// <summary>统计信息</summary>
    public PlayerStatisticsDto Statistics { get; set; } = new();
}

/// <summary>
/// 位置DTO
/// </summary>
public class PositionDto
{
    /// <summary>X坐标</summary>
    public float X { get; set; }
    
    /// <summary>Y坐标</summary>
    public float Y { get; set; }
}

/// <summary>
/// 领土DTO
/// </summary>
public class TerritoryDto
{
    /// <summary>领土ID</summary>
    public Guid Id { get; set; }
    
    /// <summary>所属玩家ID</summary>
    public Guid PlayerId { get; set; }
    
    /// <summary>边界点</summary>
    public List<PositionDto> Boundary { get; set; } = new();
    
    /// <summary>面积</summary>
    public float Area { get; set; }
}

/// <summary>
/// 活跃效果DTO
/// </summary>
public class ActiveEffectDto
{
    /// <summary>效果ID</summary>
    public Guid Id { get; set; }
    
    /// <summary>效果类型</summary>
    public string EffectType { get; set; } = string.Empty;
    
    /// <summary>开始时间</summary>
    public DateTime StartTime { get; set; }
    
    /// <summary>持续时间（秒）</summary>
    public int DurationSeconds { get; set; }
    
    /// <summary>结束时间</summary>
    public DateTime EndTime { get; set; }
    
    /// <summary>是否已过期</summary>
    public bool IsExpired { get; set; }
}

/// <summary>
/// 玩家统计DTO
/// </summary>
public class PlayerStatisticsDto
{
    /// <summary>死亡次数</summary>
    public int Deaths { get; set; }
    
    /// <summary>击杀次数</summary>
    public int Kills { get; set; }
    
    /// <summary>最大领土面积</summary>
    public float MaxTerritoryArea { get; set; }
    
    /// <summary>总移动距离</summary>
    public float TotalDistanceMoved { get; set; }
    
    /// <summary>使用道具数</summary>
    public int ItemsUsed { get; set; }
    
    /// <summary>拾取道具数</summary>
    public int ItemsPickedUp { get; set; }
    
    /// <summary>领土捕获次数</summary>
    public int TerritoryCaptures { get; set; }
}

/// <summary>
/// 游戏排名响应
/// </summary>
public class GameRankingResponse
{
    /// <summary>排名</summary>
    public int Rank { get; set; }
    
    /// <summary>玩家ID</summary>
    public Guid PlayerId { get; set; }
    
    /// <summary>玩家名称</summary>
    public string PlayerName { get; set; } = string.Empty;
    
    /// <summary>玩家颜色</summary>
    public string PlayerColor { get; set; } = string.Empty;
    
    /// <summary>领土面积</summary>
    public float TerritoryArea { get; set; }
    
    /// <summary>领土数量</summary>
    public int TerritoryCount { get; set; }
    
    /// <summary>面积占比</summary>
    public float AreaPercentage { get; set; }
    
    /// <summary>当前状态</summary>
    public string CurrentState { get; set; } = string.Empty;
    
    /// <summary>最后更新时间</summary>
    public DateTime LastUpdate { get; set; }
}

#endregion
